#include<bits/stdc++.h>
#define LL long long
#define LLL __int128
#define uint unsigned
#define ldb long double
#define uLL unsigned long long
using namespace std;
const int N=2e5+5;
const LL INF=1e18;
int n,m,q,tim,dfn[N];
uLL val[N],p[64];
vector<pair<int,int>>G[N];
mt19937_64 rnd(chrono::system_clock::now().time_since_epoch().count());
inline void dfs(int u,int fa){
	dfn[u]=++tim;
	for(auto [v,id]:G[u])if(id!=fa)
		if(dfn[v]){
			if(dfn[v]<dfn[u])val[id]=rnd();
			val[fa]^=val[id];
		}
		else dfs(v,id),val[fa]^=val[id];
}
inline void clr(){
	fill(p,p+64,0);
}
inline bool ins(uLL x){
	for(int i=64;i--;)if(x>>i&1)
		if(!p[i])return p[i]=x,1;
		else x^=p[i];
	return 0;
}
signed main(){
	cin.tie(0)->sync_with_stdio(0);
	freopen("graph.in","r",stdin);
	freopen("graph.out","w",stdout);
	cin>>n>>m;
	for(int i=1;i<=m;++i){
		int u,v;cin>>u>>v;
		G[u].emplace_back(v,i);
		G[v].emplace_back(u,i);
	}
	dfs(1,0);
	cin>>q;
	for(int i=1;i<=q;++i){
		int k,ans=0;cin>>k,clr();
		for(int j=1;j<=k;++j){
			int x;cin>>x,ans|=!ins(val[x]);
		}
		cout<<(ans?"NO\n":"YES\n");
	}
	return 0;
}
/*
*/